/*
 * Copyright 2010 Joshua Smith and Nelson Llewellyn
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package norse.server.nmap;

import java.util.LinkedList;
import java.util.List;
import norse.common.CommandLineArg;

/**
 * Configuration for an NMAP scan.
 */
public class NMAPScanConfiguration
{
//TODO: Separate configuration and scan IPs
//TODO: Replace manual command-line args with something more user-friendly

    /**
     * Constructor.
     *
     * @param _args manual command-line arguments.
     */
    public NMAPScanConfiguration(List<CommandLineArg> _args)
    {
        //Create a defensive copy of the arguments
        //Don't need to copy the actual objects, since they're immutable.
        args = new LinkedList<CommandLineArg>(_args);
    }

    /**
     * Add configuration paramters to a a ProcessBuilder command list.
     *
     * @param _commands the list to add commands to.
     */
    public void addConfigToCommandList(List<String> _commands)
    {
        for(CommandLineArg currArg : args)
        {
            _commands.add(currArg.getArg());

            if(currArg.hasParam())
            {
                _commands.add(currArg.getParam());
            }
        }
    }

    //Command line arguments
    private List<CommandLineArg> args;
}
